home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1997 #1 / Amiga Plus Extra 1997 #1.iso / programme / tools / leoutils / leotime.a < prev    next >
Text File  |  1994-06-13  |  3KB  |  165 lines

  1. ;    .        ___           .   _   .
  2. ;    |   _  _  | .. . _    /|  / \ /|
  3. ;    |  |_)/ \ | ||V||_)    | ( / ) |
  4. ;    |__|_,\_/ | |||||_,    |o \_/  |
  5. ;
  6. ;    1994-04-25
  7. ;
  8. ;    Another one disk blocker:
  9. ;    A small timing utility, requires at least OS 2 and 68020
  10. ;    Use parenthesis around the command if you require redirection, eg.
  11. ;    LeoTime "list all nohead >ram:MyList"
  12.  
  13.     include "AInclude:Include.i"
  14. ;    include "AInclude:Macros.i"
  15.  
  16.  
  17.  
  18.     section text,CODE
  19.  
  20. DOSBASE    equr    a4
  21. STARTTIME equr    d6
  22.  
  23.     movem.l    d2-d7/a2-a6,-(sp)    ; Save registers
  24.  
  25.     tst.l    d0            ; no paramters?
  26.     beq    exitcode        ;  -- exit
  27.  
  28.     movem.l a0/d0,-(sp)        ; save command address & length
  29.  
  30.  
  31.     move.l    $4.w,a6            ; This is SysBase ( = ExecBase )
  32.     lea    DosName(pc),a1        ; DosBase = OpenLib("intuition.library", 36);
  33.     moveq.l    #36,d0
  34.     jsr    _LVOOpenLibrary(a6)
  35.     move.l    d0,DOSBASE
  36.     tst.l    d0
  37.     bne.s    go_on0
  38.  
  39.     movem.l (sp)+,a0/d0        : throw away command address & length
  40.     bra    exitcode
  41.  
  42. go_on0:
  43.     btst.b    #AFB_68020,297(a6)    ; if (!(SysBase->AttnFlags))
  44.     bne.s    go_on
  45.  
  46.  
  47.     move.l    DOSBASE,a6        ;     Printf("Bad processor type\n");
  48.     lea    BadProcessorText(pc),a0
  49.     move.l    a0,d1
  50.     jsr    _LVOPrintf(a6)
  51.  
  52.     movem.l (sp)+,a0/d0        : throw away command address & length
  53.     bra    closelib
  54.  
  55. go_on:
  56.     move.l    DOSBASE,a6        ; DateStamp(&MyDate);
  57.     lea    MyDate(pc),a0
  58.     move.l    a0,d1
  59.     jsr    _LVODateStamp(a6)
  60.  
  61.     lea    MyDate(pc),a0        ; StartTime = Days*24*60 + Minutes*60*50 + Ticks
  62.     move.l    (a0)+,STARTTIME
  63.     mulu.l    #24*60,STARTTIME
  64.     add.l    (a0)+,STARTTIME
  65.     mulu.l    #60*50,STARTTIME
  66.     add.l    (a0),STARTTIME
  67.  
  68.     movem.l (sp)+,a0/d0        ; restore command address & length
  69.  
  70.     moveq.l    #'"',d1
  71.     cmp.b    (a0),d1
  72.     bne.s    no_parenthesis
  73.     cmp.b    -2(a0,d0),d1
  74.     bne.s    no_parenthesis        ; if parameter string is surrounded with parenthesis
  75.     addq.l    #1,a0            ;     ... then leave the parentheses out
  76.     subq.l    #2,d0
  77.  
  78. no_parenthesis:
  79.     lea    -1(a0,d0),a3
  80.     move.b    (a3),d7
  81.     move.b    #0,(a3)            ; Make command string NULL-terminated
  82.  
  83.     move.l    a0,-(sp)        ; Store again the command line beginning argument
  84.  
  85. ;    move.l    DOSBASE,a6        ; Execute(Command,NULL,NULL);
  86.     move.l    a0,d1
  87.     moveq.l    #0,d2
  88.     moveq.l    #0,d3
  89.     jsr    _LVOExecute(a6)
  90.  
  91. okCode:
  92.     move.l    (sp)+,a0        ; Take command line beginning argument away from stack
  93.  
  94. ;    move.l    DOSBASE,a6        ; DateStamp(&MyDate);
  95.     lea    MyDate(pc),a0
  96.     move.l    a0,d1
  97.     jsr    _LVODateStamp(a6)
  98.  
  99.     lea    MyDate(pc),a0        ; EndTime = Days*24*60 + Minutes*60*50 + Ticks
  100.     move.l    (a0)+,d0
  101.     mulu.l    #24*60,d0
  102.     add.l    (a0)+,d0
  103.     mulu.l    #60*50,d0
  104.     add.l    (a0),d0
  105.  
  106.     sub.l    STARTTIME,d0        ; Time = EndTime - StartTime
  107.  
  108.     moveq.l    #0,d3
  109.     moveq.l    #50,d4
  110.     divu.l    d4,d3:d0
  111.     asl.l    #1,d3
  112.     moveq.l    #0,d2
  113.     moveq.l    #60,d4
  114.     divu.l    d4,d2:d0
  115.     moveq.l    #0,d1
  116.     divu.l    d4,d1:d0
  117.  
  118.     lea    PrintVars(pc),a0
  119.     move.w    d0,(a0)+
  120.     move.w    d1,(a0)+
  121.     move.w    d2,(a0)+
  122.     move.w    d3,(a0)+
  123.  
  124. ;    move.l    DOSBASE,a6        ; Printf();
  125.     lea    SuccessText(pc),a0
  126.     move.l    a0,d1
  127.     lea    PrintVars(pc),a0
  128.     move.l    a0,d2
  129.     jsr    _LVOPrintf(a6)
  130.  
  131.     move.b    d7,(a3)            ; Restore original command ending character
  132.  
  133.  
  134. closelib:
  135.  
  136.     move.l    $4.w,a6            ; This is SysBase ( = ExecBase )
  137.     move.l    DOSBASE,a1        ; CloseLib(DosBase);
  138.     jsr    _LVOCloseLibrary(a6)
  139.  
  140. exitcode:
  141.     movem.l    (sp)+,d2-d7/a2-a6    ; restore registers
  142.     moveq.l    #0,d0            ; always return OK!
  143.     rts
  144.  
  145. Ver:
  146.     dc.b "$VER:LeoTime 1.0 (25.4.94) ©1994 Leopold-Soft",10,0
  147. DosName:
  148.     dc.b "dos.library",0
  149. SuccessText:
  150.     dc.b "LeoTime: %d:%02d:%02d.%02d real time.",10,0
  151. BadProcessorText:
  152.     dc.b "LeoTime: Requires at least 68020 to run!",10,0
  153.     cnop 0,4
  154.  
  155. MyDate:
  156. MyDate_Days:
  157.     ds.l    1
  158. PrintVars:
  159. MyDate_Minutes:
  160.     ds.l    1
  161. MyDate_Ticks:
  162.         ds.l    1
  163.  
  164.     END
  165.